﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Evaluant.PS4VS.Language.Reflection
{
    public class Cmdlet
    {
        public Cmdlet(string name)
            : this()
        {
            Name = name;
        }

        private Cmdlet()
        {
            Parameters = new List<Parameter>();
        }

        public string Name { get; protected set; }

        public IList<Parameter> Parameters { get; protected set; }

        internal IEnumerable<Babel.Method> GetMethods()
        {
            List<Babel.Method> methods = new List<Babel.Method>();
            Babel.Method m = new Babel.Method();
            m.Name = Name;
            m.Parameters = new List<Babel.Parameter>();
            foreach (Parameter param in Parameters)
            {
                m.Parameters.Add(new Babel.Parameter() { Name = param.Name, Description = param.Description, Display = !param.IsRequired ? param.Name : "[" + param.Name + "]" });
            }
            methods.Add(m);

            return methods;
        }
    }
}
